<%@ page contentType="text/html; charset=UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript"> 
function tjzs(){ 
var count = $("#text").val().length; 
if(count>50){ 
var nr = $("#text").val().substring(0,50); 
$("#text").val(nr); 
count=50; 
alert("字数已达到50");
} 
$("#zs").html(count); 
} 
</script>

</head>

<body>
	<div style="72px;width:202px;" > 
		<textarea id="text" style="height:70px;width:200px;" onkeydown="tjzs()" onkeyup="tjzs()" onpropertychange="if (value.length>50) value=value.substring(0,50)"></textarea> 
		已输入<b id="zs">0</b>字/最多50字
	</div>
</body>

</html>